package com.liwang.lanouhn.nvshengo.fragments;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.liwang.lanouhn.nvshengo.Info.DataInfo;
import com.liwang.lanouhn.nvshengo.R;
import com.squareup.picasso.Picasso;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by lanouhn on 2016/10/22.
 */
public class TheHostFragment extends Fragment {
    private DataInfo datainfo;
    private CircleImageView iv_head;
    private TextView tv_title;
    private TextView tv_username;
    private TextView tv_number;
    private TextView tv_notice;

    public static TheHostFragment newInstants(DataInfo info) {
        TheHostFragment theHostFragment = new TheHostFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable("datainfo", info);
        theHostFragment.setArguments(bundle);
        return theHostFragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_thehost, null);
        initView(view);
        initEvent();
        return view;
    }
    private void initView(View view) {
        iv_head = (CircleImageView) view.findViewById(R.id.iv_head);
        tv_title = (TextView) view.findViewById(R.id.tv_title);
        tv_username = (TextView) view.findViewById(R.id.tv_username);
        tv_number = (TextView) view.findViewById(R.id.tv_number);
        tv_notice = (TextView) view.findViewById(R.id.tv_notice);
    }
    private void initEvent() {
        datainfo= (DataInfo) getArguments().getSerializable("datainfo");
        Picasso.with(getActivity()).load(datainfo.getBaseRoomInfo().getAvatar()).into(iv_head);
        tv_title.setText(datainfo.getBaseRoomInfo().getBoardCastTitle());
        tv_username.setText("主播 :"+datainfo.getBaseRoomInfo().getName());
        tv_number.setText("在线人数 :"+datainfo.getOnlineCount()+"");
    }

}
